package Demo01;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 28463
 * Date: 2022—05—15
 * Time: 14:57
 */
//子类和父类不存在同名成员变量
class Base{
    public int a=1;
    public int b=2;

    public void methodA() {
        System.out.println("Base::methodA()");
    }
    public void methodB() {
        System.out.println("Base::methodB()");
    }
}
class Derived extends Base {
    public int a=3;
    public int d=4;

    public void methodA(int val) {
        System.out.println("Derived::methodA(int)"+val);
    }
    public void methodB() {
        System.out.println("Derived::methodB()");
    }
    public void test(){
        methodA();
        methodA(100);

        super.methodB();
/*        System.out.println(this.a);
        System.out.println(this.b);
        System.out.println(this.d);
        System.out.println("访问父类的a:"+super.a);*/
    }
}
public class Test02 {
    public static void main(String[] args) {
        Derived derived = new Derived();
        derived.test();
    }
}
